package usb;
import java.util.Scanner;

public class Test07 {
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       int count =0;
       int userWin=0;
       int computerWin=0;
        String[] str = {"","石头","剪刀","布"};
        System.out.println("欢迎来到石头剪刀布游戏,输入y开始游戏");
        String str1 = sc.next();
        if (str1.equals("y")){
            System.out.println("游戏开始");
            while (true){
                int random= 0;
                while (true){
                    random=(int)(Math.random() * 10);
                    if(random<=3&&random>=1){
                        break;
                    }
                }
                while (true){
                    count++;
                    System.out.println("请输入1石头,2剪刀，3布,输入除整数外全部类型都会被电击");
                    int num=sc.nextInt();
                    if(num>=0&&num<=3){
                        if(num==random){
                            System.out.println("电脑出"+str[random]+",您出的"+str[num]);
                            System.out.println("平局");
                        }else if(num==1&&random==2||num==2&&random==3||num==3&&random==1){
                            System.out.println("电脑出"+str[random]+",您出的"+str[num]);
                            System.out.println("您赢了");
                            userWin++;
                        }else {
                            System.out.println("电脑出"+str[random]+",您出的"+str[num]);
                            System.out.println("您输了");
                            computerWin++;
                        }
                        break;
                    }else {
                        System.out.println("输入错误，请重新输入");
                    }
                }
                System.out.println("是否继续游戏，y继续");
                String flog = sc.next();
                if(!flog.equals("y")){
                    break;
                }
            }
        }
        System.out.println("总对战次数"+count);
        System.out.println("您共赢了"+userWin);
        System.out.println("电脑共赢了"+computerWin);
        if (userWin>computerWin){
            System.out.println("最终您赢了");
        }else {
            System.out.println("最终电脑赢了");
        }
        System.out.println("游戏结束");
    }
}
